function bindWebGridEvent(webGrid, pagePostRetrieveFunc, dbclickFunc) {
    $(".paging-number a", webGrid).click(pagePostRetrieveFunc); //分页get转post

    webGrid.children("tbody").children("tr").mouseover(function () {
        $(this).css("background", "#FAFAFE");
        if ($(this).attr("isselected") == "true") {
            $(this).css("background", "#EEE9FF");
        }
    });

    webGrid.children("tbody").children("tr").mouseout(function () {
        $(this).css("background", "");
        if ($(this).attr("isselected") == "true") {
            $(this).css("background", "#EEE9FF");
        }
    });

    if (webGrid.attr("select1row") != undefined) { //可单选
        webGrid.children("tbody").children("tr").click(function () {
            selectRow(webGrid, $(this))
        });
    }

    //双击
    webGrid.children("tbody").children("tr").dblclick(dbclickFunc);

    //每列的宽度及样式
    copyTHeadStyleFromTd(webGrid);

};

//复制各td的class属性到th，用于设置列宽
function copyTHeadStyleFromTd(webGrid) {
    var tr2 = webGrid.find("tbody > tr"); //不能前缀 table.webgrid-table >,用级联children也可以
    if (tr2.length == 0) {
        $('th', headtr).each(function () {
            if ($(this).html().trim().toLowerCase() == "id")
                $(this).addClass("webgrid-col-w0");
        });
        return;
    }
    var tr = tr2[0];
    var headtr = webGrid.find("thead > tr");
    $('th', headtr).each(function () {
        var index = $(this).prevAll().length;
        var td = $(tr).children('td')[index];
        $(this).addClass(td.className);
    });
};


//单击选中行
function selectRow(webGrid, newSelectedRow) {
    var attr = webGrid.attr("selectedrow");
    var oldSelectedRowIndex = attr == undefined ? 0 : Number(attr);
    if (oldSelectedRowIndex > 0) {
    }

    webGrid.children("tbody").children("tr").css("background", "");
    webGrid.children("tbody").children("tr").removeAttr("isselected");
    newSelectedRow.css("background", "#EEE9FF");
    webGrid.attr("selectedrow", newSelectedRow.prevAll().length);
    newSelectedRow.attr("isselected", true);
};

//返回选中行
function getSelectedRow(webGrid) {
    var attr = webGrid.attr("selectedrow");
    var oldSelectedRowIndex = attr == undefined ? -1 : Number(attr);
    if (oldSelectedRowIndex >= 0)
        return $(webGrid.children("tbody").children("tr")[oldSelectedRowIndex]);
    return null;
};


//查找该行的关键值
function getRowKeyRaw(tr) {
    var td = tr.children("td.keyCol");
    var h = td.html()
    var s = h.trim();
    return s;
};

//查找该行的关键值,转义成Url
function getRowKey4Url(tr) {
    return encodeURIComponent(getRowKeyRaw(tr));
};

